#!python3

import curses

menu = ["Run", "Exit"]


def menuselect(stdscr, menu, num):
	for x in range(len(menu)):
		if x == num:
			stdscr.addstr(3 + x, 0, menu[x], curses.A_STANDOUT)
		else:
			stdscr.addstr(3 + x, 0, menu[x])
	stdscr.refresh()

def startprogram(currentnum):
  pass
  
currentnum = 0
stdscr = curses.initscr()
#curses.start_color()
#curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)

curses.noecho()
curses.cbreak()
curses.curs_set(0)
stdscr.keypad(1)

stdscr.addstr(0, 0, "Welcome to PiPal!\n\n\n")
stdscr.refresh()

menuselect(stdscr, menu, currentnum)

while 1:
	c = stdscr.getch()
	if c == curses.KEY_DOWN:
		currentnum = currentnum + 1
		if currentnum == len(menu):
			currentnum = currentnum - 1
		menuselect(stdscr, menu, currentnum)
	elif c == curses.KEY_UP:
		currentnum = currentnum - 1
		if currentnum < 0:
			currentnum = 0
		menuselect(stdscr, menu, currentnum)
	elif c == ord('q'):
		break  # Exit the while()
	elif c == ord("\n"):
		if currentnum == 5:
			break
		startprogram(currentnum)

#reverse curses settings
curses.nocbreak()
stdscr.keypad(0)
curses.echo()

#end the curses session
curses.endwin()